package com.example.daiyinuo.proxy;

/**
 * 静态代理优缺点
 *
 * 优点：在不修改目标对象的功能前提下, 能通过代理对象对目标功能扩展
 * 缺点：因为代理对象需要与目标对象实现一样的接口,所以会有很多代理类
 * 一旦接口增加方法,目标对象与代理对象都要维护
 */
public class TeacherDaoProxy implements ITeacherDao{
    private ITeacherDao iTeacherDao;
    public TeacherDaoProxy(ITeacherDao iTeacherDao){
        this.iTeacherDao = iTeacherDao;
    }
    @Override
    public void teach() {
        System.out.println("代理类执行操作。。。");
        iTeacherDao.teach();
        System.out.println("代理类结束操作");
    }

    @Override
    public void sayHello(String name) {
        System.out.println("代理类执行操作。。。");
        iTeacherDao.sayHello(name);
        System.out.println("代理类结束操作");
    }
}
